package logic

import (
	"context"
	"furniture/furniturerpc/furniturerpc"

	"furniture/api/internal/svc"
	"furniture/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FurnitureAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFurnitureAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FurnitureAddLogic {
	return &FurnitureAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FurnitureAddLogic) FurnitureAdd(req *types.FurnitureAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.FurnitureRpc.FurnitureAdd(l.ctx, &furniturerpc.FurnitureAddRequest{
		Title:     req.Title,
		ClassName: req.ClassName,
		BrandName: req.BrandName,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: "添加失败",
			Data:    nil,
		}, nil
	} else {
		return &types.Response{
			Code:    200,
			Message: "添加成功",
			Data:    add,
		}, nil
	}

}
